{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github"
      },
      "source": [
        "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/camenduru/text-to-video-synthesis-colab/blob/main/test_10_text_to_video_colab.ipynb)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "n2ibl97e2yM4"
      },
      "outputs": [],
      "source": [
        "%cd /content\n",
        "!pip install git+https://github.com/huggingface/diffusers transformers accelerate imageio[ffmpeg] -U einops omegaconf decord xformers==0.0.20 safetensors compel==1.2.1\n",
        "!git clone https://github.com/camenduru/modelscope-image-to-video\n",
        "\n",
        "!apt -y install -qq aria2\n",
        "model = \"camenduru/test-10\"\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/raw/main/model_index.json -d /content/model -o model_index.json\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/raw/main/vae/config.json -d /content/model/vae -o config.json\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/resolve/main/vae/diffusion_pytorch_model.bin -d /content/model/vae -o diffusion_pytorch_model.bin\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/raw/main/unet/config.json -d /content/model/unet -o config.json\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/resolve/main/unet/diffusion_pytorch_model.bin -d /content/model/unet -o diffusion_pytorch_model.bin\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/raw/main/text_encoder/config.json -d /content/model/text_encoder -o config.json\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/resolve/main/text_encoder/pytorch_model.bin -d /content/model/text_encoder -o pytorch_model.bin\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/raw/main/scheduler/scheduler_config.json -d /content/model/scheduler -o scheduler_config.json\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/raw/main/tokenizer/merges.txt -d /content/model/tokenizer -o merges.txt\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/raw/main/tokenizer/special_tokens_map.json -d /content/model/tokenizer -o special_tokens_map.json\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/raw/main/tokenizer/tokenizer_config.json -d /content/model/tokenizer -o tokenizer_config.json\n",
        "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/{model}/raw/main/tokenizer/vocab.json -d /content/model/tokenizer -o vocab.json"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "cqo7g4p2_V78"
      },
      "outputs": [],
      "source": [
        "%cd /content/modelscope-image-to-video\n",
        "# while True:\n",
        "prompt = \"waterfall\" #@param {type:\"string\"}\n",
        "negative = \"\" #@param {type:\"string\"}\n",
        "prompt = f\"\\\"{prompt}\\\"\"\n",
        "negative = f\"\\\"{negative}\\\"\"\n",
        "num_steps = 25 #@param {type:\"raw\"}\n",
        "guidance_scale = 23 #@param {type:\"raw\"}\n",
        "fps = 24 #@param {type:\"raw\"}\n",
        "num_frames = 16 #@param {type:\"raw\"}\n",
        "!python inference.py -m \"/content/model\" -p {prompt} -n {negative} -WI 512 -HI 512 -MP stabilityai/stable-diffusion-xl-base-1.0 -o /content/outputs -d cuda -x -s {num_steps} -g {guidance_scale} -f {fps} -T {num_frames} -t 1 -S"
      ]
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "provenance": []
    },
    "gpuClass": "standard",
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
